﻿<!doctype html>
<html>
	<!-- InstanceBegin template="/Templates/template1.dwt" codeOutsideHTMLIsLocked="false" -->
	<head>
		<meta charset="utf-8">
		<title>存货领用</title>
		<script type="text/javascript" src="../js/common.js"></script>
		<script type="text/javascript" src="../js/jquery.pager.js"></script>
		<link href="../css/Pager.css" type="text/css" rel="stylesheet" />
		<script type="text/javascript" src="../js/utils.js"></script>
		<link href="../css/style.css" type="text/css" rel="stylesheet" />
		<script type="text/javascript" src="../js/pagination.js"></script>
		<script type="text/javascript" src="../js/checkLogin.js"></script>
		<script type="text/javascript" src="../js/shopSelecter.js"></script>
		<script type="text/javascript" src="../js/goodsSelecter.js"></script>
		<script type="text/javascript" src="../js/doubleDate2.0.js"></script>
		<script type="text/javascript" src="../js/find.js"></script>
		<script type="text/javascript">
			var _pagination = null;

			$(function() {
				initShopSelecter();
				$("input[type=text]").val('');
			});

			/**
			 * 初始化店面选择器
			 */
			function initShopSelecter() {
				refreshInput($(".serWrapper"));
				$("#shopIsChoosed").removeAttr("checked");
				$("#shopName").attr("disabled", "disabled");

				$("#shopIsChoosed").bind("click", function() {
					var checked = $(this).attr("checked");
					if (checked) {
						$("#shopName").removeAttr("disabled");
					} else {
						$("#shopName").attr("disabled", "disabled");
						$("#shopName").empty();
					}
				});
			}

			function printDataToPage(message) {
				var $tbody = $("#storeList");
				$tbody.empty();
				// 清空数据
				$("#sup").text("共 " + message.result.len + " 条");
				var len = message.result.data.length;
				// 返回条目数
				for (var i = 0; i < len; i++) {
					//goodsID, goodsName, shopID, shopName, memberCardNo, startDate, vol, endDate,
					//raceName, extracName, customerName, mp, note
					var id = getHtmlString(getHeadIndexValue(i, message, 'id'));
					var identiCode = getHtmlString(getHeadIndexValue(i, message, 'identiCode'));
					var goodsName = getHtmlString(getHeadIndexValue(i, message, 'goodsName'));
					var shopName = getHtmlString(getHeadIndexValue(i, message, 'shopName'));
					var memberCardNo = getHtmlString(getHeadIndexValue(i, message, 'memberCardNo'));
					var vol = getHtmlString(getHeadIndexValue(i, message, 'vol'));
					var raceName = getHtmlString(getHeadIndexValue(i, message, 'raceName'));
					var note = getHtmlString(getHeadIndexValue(i, message, 'note'));
					var mp = getHtmlString(getHeadIndexValue(i, message, 'mp'));
					var customerName = getHtmlString(getHeadIndexValue(i, message, 'customerName'));
					var startDate = getHtmlString(getHeadIndexValue(i, message, 'startDate'));
					var endDate = getHtmlString(getHeadIndexValue(i, message, 'endDate'));
					var customerName = getHtmlString(getHeadIndexValue(i, message, 'customerName'));
					var endDate = getHtmlString(getHeadIndexValue(i, message, 'endDate'));
					endDate = endDate.split(' ')[0];
					var receName = getHtmlString(getHeadIndexValue(i, message, 'receName'));
					var tr = "<tr><td>" + shopName + "</td><td>" + identiCode + "</td><td>" + customerName + "</td><td>" + mp + "</td><td>" + goodsName + "</td><td>" + vol + "</td><td>" + raceName + "</td><td>" + note + "</td><td>" + startDate + "</td><td>" + endDate + "</td><td>" + receName + "</td><td><a href='#' onclick='getInventory(" + id + ")'>领用</a></td></tr>";
					$tbody.append($(tr));
				}
			}

			/**
			 * 多条件分页查询
			 */
			function search() {

				var shopId = $("#shopName").val();
				var searchName = $("#searchName").val();
				var searchMp = $("#searchMp").val();
				var identiCode = $("#identiCode").val();
				var searchRaceName = $("#searchRaceName").val();

				// 初始化代码
				_pagination = new Pagination({
					method : 'get', // 请求方法 post|get
					type : 'json', // 返回内容格式，json|text //NOT SUPPORT
					data : {
						shopId : shopId,
						customerName : searchName,
						mp : searchMp,
						identiCode : identiCode,
						raceName : searchRaceName
					},
					url : '../custinvntryrecord/find/unget', // 请求地址，注意函数会自定添加分页的两个参数
					pageSize : 10, // 页面大小
					startIndex : 0, // 服务器提供的接口页码是从几开始的，建议从0开始
					success : printDataToPage, // state 为 0 时，回调
					pagerHandler : 'pager' // 显示分页的 div 的 id
				});

			}

			/**
			 * 领用存货
			 */
			function getInventory(id) {
				if (IsEmpty(id)) {
					artAlert("领取Id 不能为空！");
				}

				artConfirm('确定领取吗？', function() {
					$.get('../custinvntryrecord/update/' + id, function(message) {
						if (IsEmpty(message)) {
							artError("没有查询到数据");
							return;
						}
						if (message.state == 0) {
							_pagination.reload();
							artAlert("领取成功！");

						} else if (message.state == 1) {
							artError(message.msg);
						} else {
							checkStateShowErrorMsgAndDealResult(JSON.stringify(message));
						}
					}, "json");
				});
			}
		</script>
	</head>
	<body>
		<div id="yinying"></div>
		<div id="yinying1"></div>

		<!-- 添加记录 弹出层 -->
		<div id="window_change" class="member_search hideDiv">
			<div class="closeTop">
				<span class="closeThe" onclick="closeParent($(this))"><img src="../images/close.png"></span>
			</div>
			<p>
				<label><span> 店面：</span>
					<select id="addShopName" onclick="openShopListPanel(this)" style=";height:20px;">
						<option value="">请选择店铺</option>
					</select></label>
				<label><span> 会员卡号：</span>
					<input type="text" id="addMemeberCardNo" style="width:85px;">
					<input type="button" onclick="checkMemberCardNo()" value="查询" class="common_btn" style="width:20px;" />
				</label>

			</p>
			<p>
				<label><span> 姓名：</span>
					<input type="text" id="addName">
				</label>
				<label><span> 电话：</span>
					<input type="text" id="addMp">
					* </label>
			</p>
			<p>
				<label><span> 存货名称：</span>
					<select id="addGoods" onclick="openGoodsListPanel(this)" style=";height:20px;">
						<option value="">请选择商品</option>
					</select> </label>
				<label><span> 剩余容量：</span>
					<input type="text" id="addVol" style="width:80px;">
					* (分数  例如：1/3)</label>
			</p>
			<p>
				<label><span> 货位：</span>
					<input type="text" id="addPlace">
				</label>
				<label><span> 过期日期：</span>
					<input type="text" class="doubledate" id="addEndTime">
					* </label>
			</p>
			<p>
				<label> <span> 备注：</span> 					<textarea id="addNote" style="width:398px; height:60px; margin-left:5px;"></textarea> </label>
			</p>
			<div class="submit_btn">
				<input type="button" value="保存信息" class="common_btn"onclick="validate()">
			</div>
		</div>

		<!-- 选择 商品名称的弹出层-->
		<div id="goodsListPanel_yinying" class="yinying" style="z-index:499;"></div>
		<div  style="z-index:500;" id="goodsListPanel" class="hideDiv">
			<div style="float: right; margin-bottom: 5px; width: 20px; height: 20px; line-height: 20px; text-align: center; background-color: #eee; margin-bottom: 5px; border: 1px solid #ccc;">
				<span id="goodsListPanel_close" style="cursor: pointer; font-size: 14px;">X</span>
			</div>
			<div class="bottom_search">
				<div class="serWrapper" >
					<input type="text" id="goodsListPanel_searchName" class="txt" >
					<strong class="refresh" onclick="$(this).prev().val('')">清空</strong>
				</div>
				<input type="button" id="goodsListPanel_search"
				style="width: auto; margin-left: 5px;" value="查询"
				class="common_btn">
			</div>
			<table cellpadding="4" cellspacing="0" border="1" width="100%">
				<thead>
					<tr>
						<th>商品Id</th>
						<th>商品名称</th>
						<th>商品扫描码</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody id="goodsListPanel_data" ></tbody>
			</table>
			<div id="goodsPager" class="pager" ></div>
		</div>

		<!-- 选择 商铺名称的列表 -->
		<div id="shopListPanel_yinying" class="yinying" style="z-index:100;"></div>
		<div id="shopListPanel" class="hideDiv">
			<div style="float: right; margin-bottom: 5px; width: 20px; height: 20px; line-height: 20px; text-align: center; background-color: #eee; margin-bottom: 5px; border: 1px solid #ccc;">
				<span id="shopListPanel_close" style="cursor: pointer; font-size: 14px;">X</span>
			</div>
			<div class="bottom_search">
				<div class="serWrapper" >
					<input type="text" id="shopListPanel_searchName" class="txt" >
					<strong class="refresh" onclick="$(this).prev().val('')">清空</strong>
				</div>
				<input type="button" id="shopListPanel_search"
				style="width: auto; margin-left: 5px;" value="查询"
				class="common_btn">
			</div>
			<table cellpadding="4" cellspacing="0" border="1" width="100%">
				<thead>
					<tr>
						<th>店面ID</th>
						<th>店面名称</th>
						<th>电话</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody id="shopListPanel_data" ></tbody>
			</table>
			<div id="shopPager" class="pager"></div>
		</div>

		<!-- 页面列表 -->
		<div class="container" id="container">
			<div class="container_R fr">
				<div class="place">
					存货领用
				</div>
				<div class="member_search">
					<P>
						<span>
							<input type="checkbox" id="shopIsChoosed" style="width: auto; height: auto;border:none;">
							店面： </span>
						<select id="shopName" onclick="openShopListPanel(this)" style="height: 20px;"></select>
						<span>姓名：</span>
						<input type="text" id="searchName" />
						<span>手机：</span>
						<input type="text" id="searchMp" />
					</P>
					<p>
						<span>识别码：</span>
						<input type="text" id="identiCode"/>
						<span>货位：</span>
						<input type="text" id="searchRaceName" />
						<input type="button" value="查询" class="btn" onclick="search()">
					</p>
				</div>
				<table width="100%" class="member_list" cellpadding="0"
				cellspacing="1" border="0">
					<caption>
						<strong>存货列表 <span id="sup">共0条</span></strong>
					</caption>
					<thead>
						<tr>
							<th>店面</th>
							<th>识别码</th>
							<th>姓名</th>
							<th>电话</th>
							<th>存货名称</th>
							<th>剩余容量</th>
							<th>货位</th>
							<th>备注</th>
							<th>存货日期</th>
							<th>过期日期</th>
							<th>经办人</th>
							<th>领用</th>
						</tr>
					</thead>
					<tbody id="storeList"></tbody>
				</table>
				<div id="pager" style="float: right;"></div>
			</div>
			<div class="fc"></div>
		</div>
		<!-- InstanceEndEditable -->
		<script type="text/javascript" src="../js/header.js"></script>
		<script type="text/javascript" src="../js/left.js"></script>
		<script type="text/javascript" src="../js/footer.js"></script>
		<script type="text/javascript">
			showTab(8, 3);
		</script>
	</body>
	<!-- InstanceEnd -->
</html>
